package com.sevennotes.classtable.data.database.daos

import androidx.lifecycle.LiveData
import androidx.room.*
import com.sevennotes.classtable.model.TableName

@Dao
interface TableNamesDAO {
  @Insert
  fun createNewTable(tableName: TableName): Long

  @Query("SELECT * FROM table_names")
  fun getAllTablesForBack(): List<TableName>

  @Query("SELECT * FROM table_names")
  fun getAllTables(): LiveData<List<TableName>>

  @Query("SELECT * FROM table_names LIMIT 1")
  fun getFirstTable(): TableName

  @Query("SELECT count(*) FROM table_names")
  fun getTableCount(): Int

  @Update
  fun updateTableName(tableName: TableName)

  @Delete
  fun deleteTableName(tableName: TableName)

  @Query("DELETE FROM table_names")
  fun clear()
}